package com.smart.village.big.screen.controller.change;

import com.smart.village.big.screen.domain.AjaxResult;
import com.smart.village.big.screen.service.ChangeACTService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.logging.Logger;

import static com.smart.village.big.screen.domain.AjaxResult.error;

/**
 * 新修改-数智农文旅数据接口
 */
@Tag(name = "新修改-数智农文旅数据接口")
@RestController
@RequestMapping("/change/agriculture/cultural/tourism")
public class ChangeACTController {
    @Autowired
    private ChangeACTService changeACTService;
    private Logger logger = Logger.getLogger(ChangeACTController.class.getName());

    @Operation(summary = "景区与住宿-点位信息-图例")
    @Parameters({
            @Parameter(description = "标签序列号-非必填", name = "tagSerialNumber", required = false)
    })
    @GetMapping("/getAllBluePlateTags")
    @ResponseBody
    public AjaxResult getAllBluePlateTags(
            @RequestParam(required = false) @Parameter(description = "标签序列号") String tagSerialNumber
    ) {
        try {
            return AjaxResult.success(changeACTService.getAllBluePlateTags(tagSerialNumber));
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }


    @Operation(summary = "景区与住宿-点位信息")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传"),
            @Parameter(description = "标签序列号-非必填", name = "tagSerialNumber", required = false)
    })
    @GetMapping("/getServiceResourcesCoordsList")
    @ResponseBody
    public AjaxResult getServiceResourcesCoordsList(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false) @Parameter(description = "标签序列号") String tagSerialNumber
    ) {
        try {
            return AjaxResult.success(changeACTService.getServiceResourcesCoordsList(townNumber, villageNumber, tagSerialNumber));
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }

    @Operation(summary = "景区与住宿-景区门票销售")
    @Parameters({

    })
    @GetMapping("/getImportentTourScence")
    @ResponseBody
    public AjaxResult getImportentTourScence(

    ) {
        try {
            return AjaxResult.success(changeACTService.getImportentTourScence());
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }

    @Operation(summary = "景区与住宿-游客反馈")
    @Parameters({

    })
    @GetMapping("/getTouristFeedback")
    @ResponseBody
    public AjaxResult getTouristFeedback(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false, defaultValue = "1") int pageNum,
            @RequestParam(required = false, defaultValue = "10") int pageSize
    ) {
        try {
            return AjaxResult.success(changeACTService.getTouristFeedback(townNumber, villageNumber, pageNum, pageSize));
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }

    @Operation(summary = "景区与住宿-旅行社")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码非 必传"),
    })
    @GetMapping("/getTravelAgency")
    @ResponseBody
    public AjaxResult getTravelAgency(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false, defaultValue = "1") int pageNum,
            @RequestParam(required = false, defaultValue = "10") int pageSize
    ) {
        try {
            return AjaxResult.success(changeACTService.getTravelAgency(townNumber, villageNumber, pageNum, pageSize));
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }

    @Operation(summary = "景区与住宿-民宿概况")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传"),
    })
    @GetMapping("/getHomestayIntroduction")
    @ResponseBody
    public AjaxResult getHomestayIntroduction(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false, defaultValue = "1") @Parameter(description = "当前页数") int pageNum,
            @RequestParam(required = false, defaultValue = "10") @Parameter(description = "每页条数") int pageSize
    ) {
        try {
            return AjaxResult.success(changeACTService.getHomestayIntroduction(townNumber, villageNumber, pageNum, pageSize));
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }

    @Operation(summary = "景区与住宿-服务资源")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码非 必传"),
            @Parameter(name = "resourceType", description = "资源类型 非 必传"),
    })
    @GetMapping("/getServiceResourcesList")
    @ResponseBody
    public AjaxResult getServiceResourcesList(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false, defaultValue = "公共厕所") String resourceType,
            @RequestParam(required = false, defaultValue = "1") int pageNum,
            @RequestParam(required = false, defaultValue = "10") int pageSize
    ) {
        try {
            return AjaxResult.success(changeACTService.getServiceResourcesList(townNumber, villageNumber, resourceType, pageNum, pageSize));
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }

    /**
     * 景区与住宿-车流客流-车流客流监控
     *
     * @return
     */
    @Operation(summary = "景区与住宿-车流客流-车流客流监控")
    @GetMapping("/getTrafficFlow")
    @ResponseBody
    public AjaxResult getTrafficFlow(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber
    ) {
        try {
            return AjaxResult.success(changeACTService.getTrafficFlow(townNumber, villageNumber));
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }


    /**
     * 景区与住宿-车流客流-车流数据分析
     *
     * @return
     */
    @Operation(summary = "景区与住宿-车流客流-车流数据分析")
    @GetMapping("/getTrafficFlowAnalysis")
    @ResponseBody
    public AjaxResult getTrafficFlowAnalysis(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber
    ) {
        try {
            return AjaxResult.success(changeACTService.getTrafficFlowAnalysis(townNumber, villageNumber));
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }


    /**
     * 景区与住宿-车流客流-实时路况监控
     *
     * @return
     */
    @Operation(summary = "景区与住宿-车流客流-实时路况监控")
    @GetMapping("/getTrafficFlowRealTime")
    @ResponseBody
    public AjaxResult getTrafficFlowRealTime(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false, defaultValue = "1") int pageNum,
            @RequestParam(required = false, defaultValue = "10") int pageSize
    ) {
        try {
            return AjaxResult.success(changeACTService.getTrafficFlowRealTime(townNumber, villageNumber, pageNum, pageSize));
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }


    /**
     * 景区与住宿-车流客流-客流趋势分析
     *
     * @return
     */
    @Operation(summary = "景区与住宿-车流客流-客流趋势分析")
    @GetMapping("/getCustomerAnalysis")
    @ResponseBody
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码非 必传"),
            @Parameter(name = "dateType", description = "日期类型 必传"),
    })
    public AjaxResult getCustomerAnalysis(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam String dateType
    ) {
        try {
            return AjaxResult.success(changeACTService.getCustomerAnalysis(townNumber, villageNumber, dateType));
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }


    /**
     * 景区与住宿-车流客流-实时客流监控
     *
     * @return
     */
    @Operation(summary = "景区与住宿-车流客流-实时客流监控")
    @GetMapping("/getCustomerRealTime")
    @ResponseBody
    public AjaxResult getCustomerRealTime(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false, defaultValue = "1") int pageNum,
            @RequestParam(required = false, defaultValue = "10") int pageSize
    ) {
        try {
            return AjaxResult.success(changeACTService.getCustomerRealTime(townNumber, villageNumber, pageNum, pageSize));
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }


    @Operation(summary = "所有景区-点位信息")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 非必传"),
            @Parameter(name = "villageNumber", description = "村编码 非必传"),
    })
    @GetMapping("/getScenicSpotCoordsList")
    @ResponseBody
    public AjaxResult getScenicSpotCoordsList(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber
    ) {
        try {
            return AjaxResult.success(changeACTService.getScenicSpotCoordsList(townNumber, villageNumber));
        } catch (Exception e) {
            e.printStackTrace();
            logger.severe(e.getMessage());
            return error("程序错误请联系系统管理员");
        }
    }

}
